counterfactual2_table <- function(){
  
  indtable <- read.csv("../release/counterfactuals/lowrisk_simplemh_censor0.2/fixedmarkup0/indmarketoutcomes.csv")
  sgtable <- read.csv("../release/counterfactuals/lowrisk_simplemh_censor0.2/fixedmarkup0/sgmarketoutcomes.csv")
  
  # Removing proportion counterfactuals
  indtable <- indtable[, c(1:2, 4, 6)]
  sgtable <- sgtable[, c(1:2, 4, 6)]
  
  # Loading standard error results
  stderrtable <- read.csv("../release/counterfactuals/bootstrap/bootstrap_stderr.csv")
  ## make necesary zeros
  stderrtable[c(1, 13:24), 2] <- 0
  ## remove labels: 
  stderrtable <- stderrtable[, -1]
  ## adding correct names: 
  names(stderrtable) <- names(indtable)
  
  tableinnardslist <- list(
    perfectshuffle_df(100 * indtable[10:12, ], 100 * stderrtable[7:9, ]),
    perfectshuffle_df(100 * indtable[13:15, ], 100 * stderrtable[10:12, ]),
    perfectshuffle_df(100 * sgtable[11:13, ], 100 * stderrtable[19:21, ]),
    perfectshuffle_df(100 * sgtable[14:16, ], 100 * stderrtable[22:24, ])
  )
  
  rownames <- list(
    c("Bronze",
      "",
      "Silver",
      "",
      "Gold",
      ""), 
    c("Bronze",
      "",
      "Silver",
      "",
      "Gold",
      ""), 
    c("Bronze",
      "",
      "Silver",
      "",
      "Gold",
      ""), 
    c("Bronze",
      "",
      "Silver",
      "",
      "Gold",
      "")
  )
  
  MakeLatexTableAdj(
    startcodelist = list(
      "\\begin{table}[H]",
      "\\centering",
      "\\caption{Counterfactual results: premiums}",
      "\\begin{tabular}{rcccc}",
      "&  &  &  & \\tabularnewline",
      "\\hline", 
      "\\hline",
      "\\multicolumn{5}{c}{Panel A: Individual market}\\\\",
      "\\multicolumn{5}{c}{(N = 178,157)}\\\\",
      "\\midrule",
      " &  & Close & Extended & Mandated \\\\",
      "Counterfactual: & Base & small group & ICHRA & insurance \\\\",
      "\\cmidrule(lr){2-2} \\cmidrule(lr){3-3} \\cmidrule(lr){4-4} \\cmidrule(lr){5-5}",
      "\\multicolumn{1}{l}{Standardized gross premiums} & & & & \\\\"), 
    tableinnardslist = tableinnardslist,
    tableinnardsroundvec = c(0, 0, 0, 0), 
    stderrlist = list(T, T, T, T),
    inbetweencodelistlist = list(
      list(
        "\\multicolumn{1}{l}{Population net premiums} & & & & \\\\"
      ), 
      list(
        "\\multicolumn{5}{c}{ } \\\\",
        "\\multicolumn{5}{c}{Panel B: Small group market} \\\\",
        "\\multicolumn{5}{c}{(Base: N = 55,374; Merged: N =  125,527)} \\\\",
        "\\midrule",
        "\\multicolumn{1}{l}{Standardized gross premiums} & & & & \\\\"
      ),       list(
        "\\multicolumn{1}{l}{Population net premiums} & & & & \\\\"
      )),
    endcodelist = list(
      "\\hline", 
      "\\hline",
      "\\end{tabular}",
      "\\label{tab:main_t_ctfls2}",
      "\\end{table}"), 
    rownames = rownames
  )
}
